package com.front.peikuahaitao.model;

import android.util.Log;

import com.front.peikuahaitao.bean.User;

import cn.bmob.v3.exception.BmobException;
import cn.bmob.v3.listener.SaveListener;


/**
 * Created by Administrator on 2016/7/21.
 */
public class LoginModel implements ILoginBiz{

    @Override
    public void getData(final String userName, final String passWord, final OnLoginListener listener) {
        if(userName .equals("13") ){
            listener.onSuccess(userName);
            User user = new User();
            user.setUserName(userName);
            user.setPassWord(passWord);
            user.save(new SaveListener<String>() {
                @Override
                public void done(String s, BmobException e) {
                    if (e == null) {
                        Log.i("---tag---", "添加数据成功，返回objectId为：" + s);
                    } else {
                        Log.i("---tag---", "创建数据失败：" + e.getMessage());
                    }
                }
            });
        }else {
            listener.onFail(passWord);
        }
    }
}
